using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Cryptography;
using System.Text;


/// <summary>
/// Summary description for Tools
/// </summary>
namespace SMS.OnLine.Common
{
    public class Tools
    {
        public static string Encryption(string input, HashAlgorithmType hashAlgorithm)
        {
            byte[] bytInput = System.Text.Encoding.UTF8.GetBytes(input);

            HashAlgorithm hash;
            switch (hashAlgorithm)
            {
                case HashAlgorithmType.SHA1:
                    hash = new SHA1Managed();
                    break;
                case HashAlgorithmType.SHA256:
                    hash = new SHA256Managed();
                    break;
                case HashAlgorithmType.SHA384:
                    hash = new SHA384Managed();
                    break;
                case HashAlgorithmType.SHA512:
                    hash = new SHA512Managed();
                    break;
                default:
                    hash = new MD5CryptoServiceProvider();
                    break;
            }
            byte[] bytOutput = hash.ComputeHash(bytInput);
            return Convert.ToBase64String(bytOutput);
        }
    }

    public enum HashAlgorithmType
    {
        SHA1 = 0,
        SHA256 = 1,
        SHA384 = 2,
        SHA512 = 3,
        MD5 = 4
    }
}